package study01;

import java.util.Objects;

public class Studeng {
    String name;
    int age;

    public Studeng(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Studeng{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Studeng studeng = (Studeng) o;
        return age == studeng.age &&
            Objects.equals(name, studeng.name);
    }


    public static void main(String[] args) {
        Studeng stu1 = new Studeng("zhangsan", 22);
        Studeng stu2 = new Studeng("zhangsan", 22);
        System.out.println(stu1.equals(stu2));
    }
}
